package com.wang.jmonkey.ca.handler.login.request;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description
 * @Author HeJiawang
 * @Date 2021/5/11 16:37
 */
public abstract class AbstractRequestHandler implements RequestHandler {

    protected boolean checkRequestMethod(HttpServletRequest request , RequestMethod requestMethod) {
        if (request.getMethod().equalsIgnoreCase(requestMethod.name())) {
            return true;
        }
        return false;
    }

    protected String getValue(JSONObject json , String parameter , String defaultValue) {
        String result = json.getString(parameter);
        if (StrUtil.isNotEmpty(result)) return result;

        return defaultValue;
    }

}
